package cyvra;

import java.awt.Frame;
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 *
 * @author CARDENASVAR
 */
public class frmPrincipal extends javax.swing.JFrame {

    public frmPrincipal() {
        initComponents();
        
        //Maximizar el form
        this.setExtendedState(JFrame.MAXIMIZED_BOTH);
        this.setTitle("CYVRA®");
        
        //carga imagen del icono
        Image icon = new ImageIcon(getClass().getResource("cyvra.png")).getImage();
        
        //coloca la imagen no es necesario this
        this.setIconImage(icon);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        opcProcesos = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        jMenuItem4 = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JPopupMenu.Separator();
        opcSalida = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jMenu1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/menu.png"))); // NOI18N
        jMenu1.setText("Sistema");

        opcProcesos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/cog.png"))); // NOI18N
        opcProcesos.setText("Procesos");
        opcProcesos.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                opcProcesosMousePressed(evt);
            }
        });
        opcProcesos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                opcProcesosActionPerformed(evt);
            }
        });
        jMenu1.add(opcProcesos);

        jMenuItem3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/role.png"))); // NOI18N
        jMenuItem3.setText("Usuarios");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem3);
        jMenu1.add(jSeparator1);

        jMenuItem4.setText("Parametros");
        jMenu1.add(jMenuItem4);
        jMenu1.add(jSeparator2);

        opcSalida.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/cancel1.png"))); // NOI18N
        opcSalida.setText("Salida");
        opcSalida.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                opcSalidaMousePressed(evt);
            }
        });
        jMenu1.add(opcSalida);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Catálogos");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 279, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void opcSalidaMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_opcSalidaMousePressed
        // TODO add your handling code here:
        
        
        //Mensaje de que no logra conexion
        if (JOptionPane.showConfirmDialog(null, "¿ Desea salir de CYVRA® ?", "Salida del Sistema", JOptionPane.YES_NO_OPTION) ==0) 
        {
            this.dispose();
        }
    }//GEN-LAST:event_opcSalidaMousePressed

    private void opcProcesosMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_opcProcesosMousePressed
        // TODO add your handling code here:
        
        //Instanciando
         frmProcesos frmprocesos = new frmProcesos(this,true); //this para heredar el icono padre, y true para no cerrar la ventana
         
         
         //muestra el form
         frmprocesos.setVisible(true);
    }//GEN-LAST:event_opcProcesosMousePressed

    private void opcProcesosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opcProcesosActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_opcProcesosActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed

       // TODO add your handling code here:
        
        //Instanciando
         frmUsuarios frmusu = new frmUsuarios(this,true); //this para heredar el icono padre, y true para no cerrar la ventana
         
         
         //muestra el form
         frmusu.setVisible(true);
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(frmPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(frmPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(frmPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(frmPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new frmPrincipal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JMenuItem opcProcesos;
    private javax.swing.JMenuItem opcSalida;
    // End of variables declaration//GEN-END:variables
}
